<script setup lang="ts">
import {onHide, onLaunch, onShow} from '@dcloudio/uni-app';
import {useAuthStore} from "@/stores/authStore";

const authStore = useAuthStore();

onLaunch(async () => {
  console.log('App Launch');
  // 启动时自动获取OpenID（如果不存在）
  if (!authStore.wxOpenid) {
    authStore.fetchWxOpenId().then(openid => {
      if (openid) {
        console.log('自动登录成功, OpenID:', openid);
      }
    });
  }
  if (!uni.getStorageSync('agreement:v1.0')) {
    uni.reLaunch({url: '/pages/agreement/index'})
  }
});

onShow(() => {
  console.log('App Show');
});

onHide(() => {
  console.log('App Hide');
});

</script>

<style>
/* #ifdef H5 || APP-PLUS */
@import 'tailwindcss' important;
/* #endif */

/* #ifndef H5 || APP-PLUS */
/* @import "tailwindcss" important; */
@import 'tailwindcss/theme.css';
@import 'tailwindcss/preflight.css';
@import 'tailwindcss/utilities.css';
/* #endif */
</style>